package org.airline.service;

import java.util.List;

import javax.annotation.Resource;

import org.airline.dao.IUserDao;
import org.airline.entity.PageBean;
import org.airline.entity.User;
import org.springframework.stereotype.Component;
@Component("UserService")
public class UserService implements IUserDao{

	private IUserDao iUserDao;
	
	public IUserDao getiUserDao() {
		return iUserDao;
	}

	@Resource(name = "UserDaoImpl")
	public void setiUserDao(IUserDao iUserDao) {
		this.iUserDao = iUserDao;
	}

	// 检测用户名是否已被注册
	@Override
	public boolean checkUserName(String userName) throws Exception {
		return this.iUserDao.checkUserName(userName);
	}

	// 检测邮箱是否已被注册
	@Override
	public boolean checkEamil(String email) throws Exception {
		return this.iUserDao.checkEamil(email) ;
	}

	// 添加用户
	@Override
	public boolean saveUser(User user) throws Exception {
		this.iUserDao.saveUser(user) ;
		return false;
	}
	//检查用户是否存在
	@Override
	public User checkUser(String userName, String password) throws Exception {
		return iUserDao.checkUser(userName, password);
	}
	
	// 检查管理是否存在
	@Override
	public User checkAdminUser(String userName, String password)
			throws Exception {
		return iUserDao.checkAdminUser(userName, password);
	}

	
	//修改用户信息
	@Override
	public void updateUser(User user) throws Exception {
		this.iUserDao.updateUser(user);
	}
	//根据id删除用户信息
	@Override
	public void deleteUserById(int id) throws Exception {
		this.iUserDao.deleteUserById(id);
	}
	//查询所有用户信息
	@Override
	public List<User> getAllUser() throws Exception {
		return this.iUserDao.getAllUser();
	}
	//根据id获取用户信息
	@Override
	public User getUserInfoById(int id) throws Exception {
		return this.iUserDao.getUserInfoById(id);
	}
	//根据关键字查询用户信息
	@Override
	public List<User> getUsersByWords(String keyWord) throws Exception {
		return this.iUserDao.getUsersByWords(keyWord);
	}
	//分页查询
	@Override
	public PageBean queryForPage(int pageSize, int page) throws Exception {
		return this.iUserDao.queryForPage(pageSize, page);
	}
	//根据关键字分页查询
	@Override
	public PageBean queryForPageByKeyWords(String keyWord, int pageSize, int page)
			throws Exception {
		return iUserDao.queryForPageByKeyWords(keyWord, pageSize, page);
	}

	
}
